<?php


namespace App\Controller\Admin;


use App\Annotation\OperationLog;
use App\Controller\AbstractController;
use App\Request\Admin\CertificationCompanyApplyIndexRequest;
use App\Request\Admin\CertificationCompanyApplyNotAllowRequest;
use App\Service\Admin\CertificationCompanyApplyService;
use Hyperf\Di\Annotation\Inject;

class CertificationCompanyApplyController extends AbstractController
{

    /**
     * @Inject()
     * @var CertificationCompanyApplyService
     */
    protected $certificationCompanyApplyService;

    /**
     * @OperationLog(event="获取企业实名审核",platform="admin")
     */
    public function index(CertificationCompanyApplyIndexRequest $request)
    {
        $where = $this->request->query();
        $index = $this->certificationCompanyApplyService->index($where);
        return $this->response->success($index);
    }

    /**
     * @OperationLog(event="企业实名审核通过",platform="admin")
     * @param int $certificationCompanyApplyId
     * @throws \Exception
     */
    public function allow(int $certificationCompanyApplyId)
    {
        $this->certificationCompanyApplyService->allow($certificationCompanyApplyId);
        return $this->response->success();
    }

    /**
     * @OperationLog(event="企业实名审核不通过",platform="admin")
     * @param int $certificationCompanyApplyId
     * @param CertificationCompanyApplyNotAllowRequest $request
     */
    public function notAllow(int $certificationCompanyApplyId,CertificationCompanyApplyNotAllowRequest $request)
    {
        $validated = $request->validated();
        $this->certificationCompanyApplyService->notAllow($certificationCompanyApplyId,$validated);
        return $this->response->success();
    }
}